home *** CD-ROM | disk | FTP | other *** search
- Path: zippy.cais.net!news
- From: mgeiger@mail.drsystems.com (Mark Geiger)
- Newsgroups: comp.lang.c
- Subject: Re: extern and static are they compatable
- Date: Thu, 04 Jan 1996 04:23:14 GMT
- Organization: Capital Area Internet Service info@cais.com 703-448-4470
- Message-ID: <4cfnu5$she@zippy.cais.net>
- References: <4cedhf$g6i@cnn.cc.biu.ac.il> <ahicksDKM8Ap.FBp@netcom.com>
- Reply-To: mgeiger@mail.drsystems.com
- NNTP-Posting-Host: 205.252.35.152
- X-Newsreader: Forte Free Agent 1.0.82
-
- ahicks@netcom.com (Aaron Hicks at Netcom) wrote:
-
- >Folks,
-
- > I'm working on a project which requires use to create large array
- >( approximately 500 K bytes ) so we decided to make it static so it would
- >not have be created each time the routines that use it are called. We then
- >found out that we needed a nother program to acess this array so in the second
- >file we defined this array as a extern. Now each time we compile and link
- >the programs we get an error stating that the array is undefined. The error
- >is displayed while linking. After reading all I could find about extern
- >I can not find any thing that says this is correct behavior.
-
- This is correct behavior. When an object (variable, function, etc) is
- declared as static its scope is limited to the module (source file) in
- which it is defined.
-
- > I then changed
- >the static decloration to a non static and the thing compiles with out a
- >problem.
-
- This is the correct way to do what you intend.
-
- > Now I'm wandering if any of the great mind on the net could
- >enlighten me as to why the static declaration would cause this error.
- >Below is a short part of the code that shows the declarations of the array.
-
- >header_file.h
- >...
-
- >typedef char Bit_Fail_Array_Type[Row_Max][Column_Max_By_Byte][Sub_Array_Max];
- >...
-
- >raster.c
- >...
- >/* Global declaration of the array to hold the failed bits */
- >static Bit_Fail_Array_Type bit_fail_array_table;
- >...
-
- >raster_analysis.c
- >...
- >/* Declare the array that hold the failed bits to analysis */
- >extern Bit_Fail_Array_Type bit_fail_array_table;
- >...
-
-
- >Thanks in Advance and Happy New Year
-
- >Aaron Hicks
- >ahicks@netcom.com
-
-
-